package com.lagou.service;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Waiting
 * @date 2020/7/10 上午 11:17
 */
@Service
public class ConsumerService {

    private static ExecutorService executor = Executors.newFixedThreadPool(4);

    @Reference(check = false,loadbalance = "random")
    private HelloService helloService;


    public String sayHello(String name) {
        return helloService.sayHello(name);
    }


    public void cal() {
        for (int i = 0; i < 100000; i++) {
            executor.submit(() -> { helloService.methodA();});
            executor.submit(() -> { helloService.methodB();});
            executor.submit(() -> { helloService.methodC();});
        }
    }
}
